/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.longview.io.modules.base.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.longview.io.common.persistence.Page;
import com.longview.io.common.service.CrudService;
import com.longview.io.modules.base.entity.Station;
import com.longview.io.modules.base.dao.StationDao;

/**
 * 站点基础信息表Service
 * @author zf
 * @version 2017-09-18
 */
@Service
@Transactional(readOnly = true)
public class StationService extends CrudService<StationDao, Station> {
	@Autowired
	private StationDao stationDao;
	public Station get(String id) {
		return super.get(id);
	}
	
	/*
	 * add by muzili90 2017-10-24 根据station_code 查询station
	 */
	public Station getStationByStationCode(String stationCode) {
		Station station=new Station();
		station.setStationCode(stationCode);
		return stationDao.getStationByStationCode(station);
	}
	
	/*
	 * add by muzili90 2017-10-24 select in stationCodes
	 */
	//根据stationCode数组查询List<Station>
	public List<Station> getStationsByStationCodes(String[] stationCodes) {
		return stationDao.getStationsByStationCodes(stationCodes);
	}
	
	public List<Station> findList(Station station) {
		return super.findList(station);
	}
	
	public Page<Station> findPage(Page<Station> page, Station station) {
		return super.findPage(page, station);
	}
	
	@Transactional(readOnly = false)
	public void save(Station station) {
		super.save(station);
	}
	
	@Transactional(readOnly = false)
	public void delete(Station station) {
		super.delete(station);
	}
	
	/**
	 * 查询所有站点 add by zf
	 */
	public List<Station> findAllList() {
		Station s = new Station();
		return stationDao.findAllList(s);
	}
	/**
	 * 借助中间表同步站点area_id
	 */
	@Transactional(readOnly = false)
	public void updateCityId(Station station){
		List<Station> stations = findList(station);
		for(int i=0;i<stations.size();i++){
			Station stationCurr = stations.get(i);
			//只更新内蒙古本地站点数据
			if(stationCurr.getIsLocal().equals("1"))
				dao.updateCityId(stationCurr);
		}
	}
	
	/**
	 * add by muzili90
	 * 2017-10-17
	 * 获取内蒙古站点排除已C开头的站点
	 */
	public List<Station> findAllExcludeHeaderC(){
		return stationDao.findAllExcludeHeaderC();
	}
	
	/**
	 * add by YanXing 2017-11-02
	 * @return 内蒙本地首府站点列表
	 */
	public List<Station> findAllLocalCapitalStation(){
		Station station = new Station();
		station.setIsLocal("1");//是内蒙本地
		station.setIsCapital("1");//是首府
		return super.findList(station);
	}
}